<include file="Public:head" />
<link href="__APP__/Application/{$Think.MODULE_NAME}/Public/css/home.css" rel="stylesheet" type="text/css" />
<script src="__PUBLIC__/js/jquery/validate.js"></script>
<script type="text/javascript">
    $(function(){
        $("#form").validate({
            errorPlacement: function(error, element){
                var error_td = element.parent('div');
                error_td.find('label.error').hide();
                error_td.append(error);
            },
            submitHandler:function(form){
                addMessages();
            },
            rules: {
                content:{
                    required : true
                },
                code : {
                    required : true,
                    remote   : {
                        url : "{:U('Ajax/checkCode')}",
                        type: 'post',
                        data:{
                            code : function(){
                                return $('#code').val();
                            }
                        }
                    }
                }
            },
            messages: {
                content:{
                    required : '留言内容不能为空'
                },
                code : {
                    required : '请输入验证码',
                    remote	 : '验证码有误'
                }
            }
        });
        $("#getcode_gg").click(function(){
            $(this).attr("src",'__PUBLIC__/js/group/code_gg.php?' + Math.random());
        });
    });
    function addMessages(){
        var word = "成功提交留言";
        var content = $("textarea[name=content]").val();
        var sid = "{$Think.get.id}";
        $.post("{:U('Ajax/addMessages')}",{
            content:content,
            sid:sid,
            mtype:0
        },function(data){
            showTip('系统提示',word,'2',1.5,'',0);
        })
    }
    function reply(id){
    $('#messageArea').show();
        toTaskObject("textarea[name=content]");
        $("textarea[name=content]").val("#"+id+"# ")
        $("textarea[name=content]").focus();
    }
   
</script>
<div id="wrap">
    <div id="school">{$type=0|getAreaName}
        <a href="__APP__/?type=clean">[切换位置]</a>
        <span>/</span>
        <em>餐厅留言</em>
    </div>
    <div id="container" class="clearfix">
        <div id="pCenter" class="shadow clearfix">
            <include file="Public:left" />

            <div class="sup_mess">
                 <div id="sysNotice">
                    <h1>餐厅留言</h1>
                     <empty name="lists">
                    <div class="sys_con">
                        <p class="not_title">
                            <span>暂时还没有餐厅留言...</span>
                        </p>
                    </div>
                         </empty>
                </div>
<notEmpty name="lists">
                <foreach name="lists" item="row">
                    <div class="sm_list">
                        <p>{$row.content}</p>
                        <p>
                            <span class="sm_nick">
                                <if condition="$row.uid gt 0">{$row.uid|is_shop_admin=###}<else/>游客 {$row.uid2}</if></span><span class="sm_time">
                                {$row.addtime|tranTime=###}</span></p>


                        <foreach name="row['sub']" item="row2">
                            <div class="reply_info">
                                <p>{$row2.content}</p>
                                <p>
                                    <span class="sm_nick"><if condition="$row2.uid gt 0">{$row2.uid|is_shop_admin=###}<else/>游客 {$row2.uid2}</if></span>
                                    <span class="sm_time">{$row2.addtime|tranTime=###}</span><a href="javascript:;" onclick="reply('{$row.id}')" class="sm_reply">回复</a>
                                </p>
                            </div>
                        </foreach>
                    </div>
                </foreach>
                <div class="page">{$page}</div>
                 </notEmpty>
                <div class="make_msg" style="display: none" id="messageArea">
                    <form id="form" method="POST" > 
                        <div style="margin:20px 0 0">
                            <label style="width:50px;">留言：</label>
                            <textarea  name="content" autocomplete="off">{$messages}</textarea>
                        </div>
                        <div class="chk_code" style="margin:20px 0 0">
                            <label style="width:50px;">验证码：</label>
                            <input type="text" class="input login_input_1" name="code"  id="code"  tabindex="3" autocomplete="off" />
                            <img src="__PUBLIC__/js/group/code_gg.php" id="getcode_gg" title="看不清，点击换一张" align="absmiddle">

                        </div>
                        <div class="btn" style="margin-top: 10px;">
                            <input type="submit" value="提交" id="btnSendClick" />
                        </div>
                    </form>
                </div>

            </div>
            <!--end of pAccount-->
        </div>
    </div>
    <!--end of pCenter-->
</div>
<include file="Public:foot" />